package com.prs.crm.domain.sale;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.crm.Customer;

@Entity
@Table(name = "sale_quotationsheet")
public class QuotationSheet extends FlowCodeEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	/**
	 * 报价单主题
	 */
	private String quotationName;

	/**
	 * 报价单编号
	 * 
	 */
	private String quotationCode;

	/**
	 * 报价日期
	 */

	private Date quotationDate;

	/**
	 * 关联客户
	 */
	@ManyToOne
	private Customer customer;
	/**
	 * 报价明细
	 */
	@OneToMany(mappedBy = "quotationsheet")
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<QuotationDetail> quodetails;
	/**
	 * 报价备注
	 */
	@Lob
	private String quotationRemark;

	/**
	 * 产品批号
	 * 
	 * @return
	 */
	private String batchNum;
	
//	@OneToOne(fetch=FetchType.LAZY,mappedBy="quotationsheet")
//	private Code code;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getQuotationName() {
		return quotationName;
	}

	public void setQuotationName(String quotationName) {
		this.quotationName = quotationName;
	}

	public String getQuotationCode() {
		return quotationCode;
	}

	public void setQuotationCode(String quotationCode) {
		this.quotationCode = quotationCode;
	}

	public Date getQuotationDate() {
		return quotationDate;
	}

	public void setQuotationDate(Date quotationDate) {
		this.quotationDate = quotationDate;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Set<QuotationDetail> getQuodetails() {
		return quodetails;
	}

	public void setQuodetails(Set<QuotationDetail> quodetails) {
		this.quodetails = quodetails;
	}

	public String getQuotationRemark() {
		return quotationRemark;
	}

	public void setQuotationRemark(String quotationRemark) {
		this.quotationRemark = quotationRemark;
	}

	public void addDetail(QuotationDetail detail) {
		if (quodetails == null)
			quodetails = new HashSet<QuotationDetail>();
		detail.setQuotationsheet(this);
		quodetails.add(detail);
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

//	public Code getCode() {
//		return code;
//	}
//
//	public void setCode(Code code) {
//		this.code = code;
//	}

}
